import type { VxeGridProps } from '#/adapter/vxe-table'
import { getFormkeyByLocale } from '#/utils/localesConfig'
import { sellerPageApi } from '#/views/customer/seller/use/api'
import { channelPageApi } from '#/views/resource/channel/use/api'
import { sitePageApi } from '#/views/system/site/use/api'
import { $t } from '@vben/locales'
// 商品
export const goodsColumns: VxeGridProps['columns'] = [
    { align: 'center', title: '', type: 'checkbox', width: 80 },
    { title: $t('common.serialNumber'), type: 'seq', width: 50 },
    {
        field: getFormkeyByLocale('channelName'),
        title: $t('page.resource.children.goods.children.goodsInformation.children.form.channel')
    },
    {
        field: 'id',
        title: $t('page.orderFormFiled.children.goodsId')
    },
    {
        field: 'name',
        title: $t('page.resource.children.tasktag.children.goodsName')
    },
    {
        field: 'code',
        title: $t('page.resource.children.goods.children.goodsInformation.children.form.goodsCode')
    },
    {
        field: 'action',
        fixed: 'right',
        slots: { default: 'action' },
        title: $t('common.action'),
        width: 120
    }
]
export const goodsSchema = [
    {
        fieldName: 'channelId',
        label: $t('page.orderFormFiled.children.channel'),
        component: 'TableSelect',
        componentProps: {
            options: [],
            selectWidth: '180px',
            labelKey: getFormkeyByLocale('name'),
            formOptions: {
                schema: [
                    {
                        component: 'Input',
                        defaultValue: '',
                        fieldName: getFormkeyByLocale('name'),
                        label: $t('page.resource.children.channel.children.table.name'),
                        formItemClass: 'col-span-2'
                    }
                ]
            },
            columns: [
                {
                    title: $t('page.orderFormFiled.children.channel'),
                    field: getFormkeyByLocale('name')
                }
            ],
            api: channelPageApi.getPageList,
            multiple: false
        }
    },
    {
        fieldName: 'id',
        label: 'Id',
        component: 'Input'
    },
    {
        fieldName: 'name',
        label: $t('page.resource.children.tasktag.children.goodsName'),
        component: 'Input'
    }
]
// 创作者
export const creatorColumns: VxeGridProps['columns'] = [
    { align: 'center', title: '', type: 'checkbox', width: 80 },
    { title: $t('common.serialNumber'), type: 'seq', width: 50 },
    {
        field: 'logo',
        title: $t('page.customer.children.creator.children.form.creatorAvatar'),
        cellRender: { name: 'CellImage' }
    },
    { field: 'niackName', title: $t('page.customer.children.creator.children.form.creatorName') },
    {
        field: 'creatorType',
        title: $t('page.customer.children.creator.children.form.creatorIdentity')
    },
    { field: 'id', title: $t('page.customer.children.creator.children.form.creatorId') },
    {
        field: 'action',
        fixed: 'right',
        slots: { default: 'action' },
        title: $t('common.action'),
        width: 120
    }
]

export const creatorSchema = [
    {
        fieldName: 'id',
        label: $t('page.customer.children.creator.children.form.creatorId'),
        component: 'Input'
    },
    {
        fieldName: 'niackName',
        label: $t('page.customer.children.creator.children.form.creatorName'),
        component: 'Input'
    }
]

// 卖家
export const sellerColumns: VxeGridProps['columns'] = [
    { align: 'center', title: '', type: 'checkbox', width: 80 },
    { title: $t('common.serialNumber'), type: 'seq', width: 50 },
    // 卖家logo列
    {
        field: 'logo',
        title: $t('page.customer.children.seller.children.form.logo'),
        cellRender: { name: 'CellImage' }
    },
    // 卖家名称列
    { field: 'name', title: $t('page.customer.children.seller.children.form.name') },
    // 卖家ID列
    {
        field: 'action',
        fixed: 'right',
        slots: { default: 'action' },
        title: $t('common.action'),
        width: 120
    }
]

export const sellerSchema = [
    {
        fieldName: 'siteId',
        label: $t('page.orderFormFiled.children.site'),
        component: 'TableSelect',
        componentProps: {
            options: [],
            selectWidth: '180px',
            labelKey: getFormkeyByLocale('name'),
            formOptions: {
                schema: [
                    {
                        component: 'Input',
                        defaultValue: '',
                        fieldName: getFormkeyByLocale('name'),
                        label: $t('page.orderFormFiled.children.site'),
                        formItemClass: 'col-span-2'
                    }
                ]
            },
            columns: [
                {
                    title: $t('page.system.children.site.children.form.name'),
                    field: getFormkeyByLocale('name')
                }
            ],
            api: sitePageApi.getPageList,
            multiple: false
        }
    },
    {
        fieldName: 'sellerUserId',
        label: $t('page.customer.children.seller.children.form.name'),
        component: 'TableSelect',
        componentProps: {
            options: [],
            selectWidth: '180px',
            formOptions: {
                schema: [
                    {
                        component: 'Input',
                        defaultValue: '',
                        fieldName: 'name',
                        label: $t('page.customer.children.seller.children.form.name'),
                        formItemClass: 'col-span-2'
                    }
                ]
            },
            columns: [
                {
                    title: $t('page.customer.children.seller.children.form.name'),
                    field: 'name'
                }
            ],
            api: sellerPageApi.getPageList,
            multiple: false
        }
    }
]
